
var mesg = {
  clear:function(){
    $('#notice-div').text("");
    $('#error-div').text("");
  },
  error:function(txt){
    $('#error-div').text(txt);
  },
  notice:function(txt){
    $('#notice-div').text(txt);
  }
};
  
var views = {
  _viewList:{},
  get:function(id){
    return this._viewList[id];
  },
  create:function(id, url){
    var view = {};
    view.onViewOpen = function(){};
    view.onViewClose = function(){};
    view.elem = {};
    $.get(url, function(response){
      view.elem = $('<div class="view"></div>').append(response).hide();
      $('#main-content').html(view.elem);
    });
    
    view.open = function(){
      $('.view').hide();
      view.onViewOpen();
      view.elem.show();
    };
    
    view.fill = function(clazz, data){
      views._fillUseClass(view.elem, clazz, data);
    };
    
    this._viewList[id] = view;
  },
  clearInputs:function(){
    $(':input').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');
  },
  _fillUseClass:function(elem ,clazz, data){
    var temp = elem.find('.' + clazz);
    if(data instanceof Array){
      var parent = temp.parent();
      parent.html('');
      for(var i = 0; i < data.length; i++){
        var obj = data[i];
        var t = temp.clone().removeClass(clazz);
        for(var e in obj){
          t.find("." + e).text(obj[e]);
          parent.append(t);
        }
      }
    }else{
      for(var e in data){
        temp.find("." + e).text(data[e]);
      }
    }
  }
};